﻿#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int fbnq1(int n)
{
	if (n <= 2)
		return 1;
	else
		return fbnq1(n - 1) + fbnq1(n - 2);
}

int fbnq2(int n)
{
	int a = 1, b = 1, c = 1;
	int t = 0;
	if (n <= 2)
		return c;
	else
		for (t = 0; t < n-2; t++)
		{
			c = a + b;
			a = b;
			b = c;
		}
	return c;
}

int main()
{
	int n = 0;
	printf("请输入想求的斐波那契数字的序数：");
	scanf("%d", &n);
	int i = fbnq1(n);//用递归法求斐波那契数列
	int j = fbnq2(n);//用迭代法求斐波那契数列
	printf("%d %d", i, j);
	return 0;
}